package com.lebang.configuration.redis;

import com.lebang.configuration.thread.DownApkThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;

/**
 * @Author hwq
 * @Date 2018/10/27 20:56
 */
@Component
@Profile("!test")
@Slf4j
public class RedisKeyExpiredConfig implements CommandLineRunner {

    @Value("${info.recoded-log}")
    private Boolean isRecodedLog;
    @Resource(name = "xianyu")
    private JedisPool jedisPool;

    @Override
    public void run(String... strings) {
        // 启动发送通知道的线程，每个程序都启动一个
//        if (isRecodedLog) {
//            LogThread thread = new LogThread();
//            thread.start();
//        }
        //下载apk包的线程
        DownApkThread downApkThread = new DownApkThread();
        downApkThread.start();
//        //一元提现的
//        String str = UUIDUtil.M();
//        //设置1小时的锁1小时内其他应用不用重复加载每日任务
//        boolean lock = redisClient.tryGetDistributedLock("runstarpsubscribe", str, 3600000);
//        if (lock) {
//            memberService.starWxOneCode();
//            //加载一元提现邀请码
//        }
//        try (Jedis jedis = jedisPool.getResource()){
//            jedis.psubscribe(new MyListener(), "listen_open_control");
//        }


    }
}
